//
//  ShopperCell.m
//  wtshoppingcite
//
//  Created by TW on 15-1-19.
//  Copyright (c) 2015年 TW. All rights reserved.
//

#import "ShopperCell.h"

@implementation ShopperCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews{
    
    _iconImageView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 100, 80)];
    [self.contentView addSubview:_iconImageView];
    
    _titleLable = [[UILabel alloc]initWithFrame:CGRectMake(_iconImageView.right + 10, _iconImageView.top, kWidth-_iconImageView.width - 20, 20)];
    [self.contentView addSubview:_titleLable];
    _titleLable.font = [UIFont systemFontOfSize:15.0f];
    _titleLable.backgroundColor = [UIColor clearColor];
    _titleLable.numberOfLines = 0;
    _titleLable.textColor = MAIN_BLACK_COLOR;
    
    _subTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(_titleLable.left, _titleLable.bottom+2,kWidth-_iconImageView.width - 20, 20)];
    [self.contentView addSubview:_subTitleLabel];
    _subTitleLabel.font = [UIFont systemFontOfSize:13.0f];
    _subTitleLabel.backgroundColor = [UIColor clearColor];
    _subTitleLabel.numberOfLines = 2;
    _subTitleLabel.textColor = UIColorFromRGB(0x9fa0a0);
    
    _scoreView = [[JPScoreView alloc]initWithFrame:CGRectMake(_titleLable.left, _subTitleLabel.bottom+20, kWidth-20, 20)];
    [self.contentView addSubview:_scoreView];
    
    
    UIView *seperateLine = [[UIView alloc]initWithFrame:CGRectMake(3, 99 - 1, kWidth-6, 0.5)];
    seperateLine.backgroundColor = MAIN_GRAY_COLOR;
    [self.contentView addSubview:seperateLine];
}

-(void)setShopperModel:(ShopperModel *)shopperModel{
    
    if (_shopperModel != shopperModel) {
        _shopperModel = shopperModel;
        
        
        [_iconImageView  setImageWithURL:[NSURL URLWithString:self.shopperModel.logoPath] placeholderImage:[UIImage imageNamed:@"all_defalutImage"]];
        _titleLable.text = self.shopperModel.shopName;
        _subTitleLabel.text = self.shopperModel.hint;
        CGSize size = [_subTitleLabel.text getSizeOfString:[UIFont systemFontOfSize:13] constroSize:CGSizeMake(220, MAXFLOAT)];
        if(size.height > 20){
            _subTitleLabel.height = size.height;
        }
        _scoreView.score = [self.shopperModel.level integerValue];
        
    }
}



@end
